﻿using www.w3.org.Item2001.XMLSchema;

namespace Sidvall.CodeGenerator.DataObjects
{
    public class SchemaAttribute : SchemaItem
    {
        public attribute Item { get; set; }

        public override string ToString()
        {
            return this.Item.Content.name;
        }
    }

    public class SchemaAttributeCollection : System.Collections.ObjectModel.KeyedCollection<attribute, SchemaAttribute>
    {

        #region Business Members

        #region Add

        public void Add(schema parent, attribute item, string fileName)
        {
            SchemaAttribute value;

            if (parent == null)
                throw new System.ArgumentNullException("parent");
            if (item == null)
                throw new System.ArgumentNullException("item");
            if (Contains(item))
                return;

            value = new SchemaAttribute()
            {
                Item = item,
                Parent = parent,
                FileName = fileName
            };
            Add(value);
        }

        #endregion
        #region GetKeyForItem

        protected override attribute GetKeyForItem(SchemaAttribute item)
        {
            if (item == null)
                throw new System.ArgumentNullException("item");
            return item.Item;
        }

        #endregion

        #endregion
        #region Constructors

        public SchemaAttributeCollection()
        {
        }

        #endregion

    }
}
